<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

/**
 * Description of banner_model
 * 
 * @author Subha Sundar Das (subhasundar.das@gmail.com)
 */
class Banner_model extends CI_Model {

    function __construct() {
        parent::__construct();
        log_message('debug', 'Model Initialized');
    }
//--get_banner Single --//
    function get_banner($size=null){
      $sql = "Select * from Banner where status=51 and size = '$size' order by RAND() limit 1";
      $query = $this->db->query($sql);
      return $query->row(); 
    }
    
//--Get Banners from Banner Table (Subha)--//    
    function get_banners(){
        $sql = "Select * from Banner where status=51 order by id desc";
        $query = $this->db->query($sql);
        $result = $query->result();
        return $result;
    }
    
//--Insert Banner --//
    function insert_banner($param) {
        if($param){
            $this->db->insert('banner',$param);
        }
    }
//--Delete Banner --//
    function delete_banner($id,$image_file) {
        if($id && $image_file){
            $sql="delete from banner where id = $id";
            $this->db->query($sql);
            //--Delete Image File --//
            $f = BASEPATH.'../assets/images/data/advertisement/'.$image_file;
            unlink($f);
        }
    }
    
}
?>